//
//  EvaluateView.m
//  wtshoppingcite
//
//  Created by TW on 14-11-14.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "EvaluateView.h"

@implementation EvaluateView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithFrame:(CGRect)frame type:(TAB_ITEM_TYPE)type
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}


- (void)initWithLineItemNames:(NSArray *)itemNames scoreNames:(NSArray *)scoreNames

{
    UIImageView * line = [[UIImageView alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.frame) - 1, CGRectGetWidth(self.frame), 1)];
    line.backgroundColor = COLOR_RGBA(220, 220, 220, 1);
    [self addSubview:line];
    
    int count = [itemNames count];
    float width = CGRectGetWidth(self.frame) / count;
    float height = CGRectGetHeight(self.frame);
    
    for (int i = 0; i < count; i ++) {
        UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(width * i + i * 1 , 5, width, 15)];
        [btn setTitle:[itemNames objectAtIndex:i] forState:UIControlStateNormal];
        btn.tag = 1000 + i;
        [btn setTitleColor:UIColorFromRGB(0x9fa0a0) forState:UIControlStateNormal];
        [btn.titleLabel setFont:[UIFont boldSystemFontOfSize:13]];
        [self addSubview:btn];
        
        UILabel *textLabel = [[UILabel alloc]initWithFrame:CGRectMake(btn.center.x - 12 , btn.bottom-2 , width, 20)];
        textLabel.text = [scoreNames objectAtIndex:i];
        textLabel.textColor = MAIN_BLUE_COLOR;
        textLabel.font = [UIFont systemFontOfSize:11.0f];
        [self addSubview:textLabel];
        
        
        if (i < count - 1) {
            UIView *seperate = [[UIView alloc]initWithFrame:CGRectMake(btn.right, btn.top + 5, 1, height -15)];
            seperate.backgroundColor = MAIN_GRAY_COLOR;
            [self addSubview:seperate];
        }
    }
}


@end
